<template>
  <p-card :bordered="false">

    <div>
      <p-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :scroll="tableScroll"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        @change="handleTableChange">

          <template slot="status" slot-scope="text, record">
            <p-switch size="small"  v-model="record.status" @change="onSwitchChange(record)" />       
          </template>

          <span slot="action" slot-scope="text, record">
            <a @click="showEditSprcModal(record)">编辑</a>

            <p-divider type="vertical" />
            <p-dropdown>
              <a class="ant-dropdown-link">更多 <p-icon type="down" /></a>
              <p-menu slot="overlay">
                <p-menu-item>
                  <p-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
                  </p-popconfirm>
                </p-menu-item>
                  <template v-if="cgButtonLinkList && cgButtonLinkList.length>0" v-for="(btnItem,btnIndex) in cgButtonLinkList">
                    <p-menu-item :key=" 'cgbtnLink'+btnIndex " v-if="showLinkButton(btnItem,record)">
                      <a href="javascript:void(0);" @click="cgButtonLinkHandler(record,btnItem.buttonCode,btnItem.optType)">
                        <p-icon v-if="btnItem.buttonIcon" :type="btnItem.buttonIcon" />
                        {{ btnItem.buttonName }}
                      </a>
                    </p-menu-item>
                  </template>
              </p-menu>
            </p-dropdown>
          </span>
      </p-table>
    </div>
    <!-- table区域-end -->


    <!-- 新增规格弹窗  -->
    <p-modal v-model="isShowEditSprcModal" title="修改规格"  @cancel='cancelEditSprc' @ok="okEditSprc">
      <p-form-model
        ref="ruleForm"
        :model="form"
        :rules="rules"
        :label-col="{
          span: 8
        }"
        :wrapper-col="{
          span: 8
        }"
      >
        <p-form-model-item ref="productSeries" label="产品系列" prop="productSeries">
          <p-input
            style="width: 200px"
            v-model="form.productSeries"
            disabled
            @blur="
              () => {
                $refs.productSeries.onFieldBlur();
              }
            "
          />
        </p-form-model-item>
        <p-form-model-item ref="productCode" label="产品编码" prop="productCode">
          <p-input
            style="width: 200px"
            disabled
            v-model="form.productCode"
            @blur="
              () => {
                $refs.productCode.onFieldBlur();
              }
            "
          />
        </p-form-model-item>
        <p-form-model-item ref="productName" label="产品名称" prop="productName">
          <p-input
            style="width: 200px"
            disabled
            v-model="form.productName"
            @blur="
              () => {
                $refs.productName.onFieldBlur();
              }
            "
          />
        </p-form-model-item>

        <p-form-model-item ref="boxLength"         
          label="纸箱长:" prop="boxLength">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.boxLength"
            min="1"
            @blur="
              () => {
                $refs.boxLength.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item>

        <p-form-model-item ref="boxWidth" label="纸箱宽" prop="boxWidth">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.boxWidth"
            min="1"
            @blur="
              () => {
                $refs.boxWidth.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item>



        <p-form-model-item ref="boxHigh" label="纸箱高" prop="boxHigh">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.boxHigh"
            min="1"
            @blur="
              () => {
                $refs.boxHigh.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item> 


        <p-form-model-item ref="bindNumber" label="捆扎次数" prop="bindNumber">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.bindNumber"
            min="1"
            @blur="
              () => {
                $refs.bindNumber.onFieldBlur();
              }
            "
          />
        </p-form-model-item>


        <p-form-model-item ref="stackingLayers" label="码垛层数" prop="stackingLayers">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.stackingLayers"
            min="1"
            @blur="
              () => {
                $refs.stackingLayers.onFieldBlur();
              }
            "
          />
        </p-form-model-item>

        <p-form-model-item ref="horizontalNumber" label="每层放置数" prop="horizontalNumber">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.horizontalNumber"
            min="1"
            @blur="
              () => {
                $refs.horizontalNumber.onFieldBlur();
              }
            "
          /> 
        </p-form-model-item>

        <p-form-model-item ref="horStrapNumber" label="水平捆包数" prop="horStrapNumber">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.horStrapNumber"
            min="1"
            @blur="
              () => {
                $refs.horStrapNumber.onFieldBlur();
              }
            "
          />
        </p-form-model-item>      
        <p-form-model-item ref="virStrapNumber" label="垂直捆包数" prop="virStrapNumber">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.virStrapNumber"
            min="1"
            @blur="
              () => {
                $refs.virStrapNumber.onFieldBlur();
              }
            "
          />
        </p-form-model-item> 
              
        <p-form-model-item ref="palletLength" label="托盘长度" prop="palletLength">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.palletLength"
            min="1"
            @blur="
              () => {
                $refs.palletLength.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item>             

        <p-form-model-item ref="palletWidth" label="托盘宽度" prop="palletWidth">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.palletWidth"
            min="1"
            @blur="
              () => {
                $refs.palletWidth.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item> 
        
        <p-form-model-item ref="angleHigh" label="护角高度" prop="angleHigh">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.angleHigh"
            min="1"
            @blur="
              () => {
                $refs.angleHigh.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item>        

        <p-form-model-item ref="coverPlateLength" label="盖板长度" prop="coverPlateLength">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.coverPlateLength"
            min="1"
            @blur="
              () => {
                $refs.coverPlateLength.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item> 

        <p-form-model-item ref="coverPlateWidth" label="盖板宽度" prop="coverPlateWidth">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.coverPlateWidth"
            min="1"
            @blur="
              () => {
                $refs.coverPlateWidth.onFieldBlur();
              }
            "
          /> mm
        </p-form-model-item> 

        <p-form-model-item ref="fullBoxSize" label="满盒数量" prop="fullBoxSize">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.fullBoxSize"
            min="1"
            @blur="
              () => {
                $refs.fullBoxSize.onFieldBlur();
              }
            "
          />
        </p-form-model-item>          

        <p-form-model-item ref="trunkFul" label="满箱数量" prop="trunkFul">
          <p-input-number
            :value="text"
            :precision="0"
            :formatter="limitNumber"
            :parser="limitNumber"
            v-model="form.trunkFul"
            min="1"
            @blur="
              () => {
                $refs.trunkFul.onFieldBlur();
              }
            "
          />
        </p-form-model-item>

      </p-form-model>
    </p-modal>    

    <ProgramInfoModal ref="modalForm" :EnhanceJS="EnhanceJS"  @ok="modalFormOk"></ProgramInfoModal>
     <!-- 弹出窗 -->
     <Fx-compontens-modal @ok="modalFormOk"  ref="modalCompon" :getList="queryInfo" :title="title" :dictOptions="dictOptions"></Fx-compontens-modal>
  </p-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {api} from '@/api/manage'
  import JSuperQuery from '@/components/jeecg/JSuperQuery.vue'
  import { filterObj, timestampToDatetime } from '@/utils/util';
  import pick from 'lodash.pick'
  import Vue from 'vue'
  import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
  import ButtonExpHandler from '@/components/jeecgbiz/modules/ButtonExpHandler'
  import { postAction,getAction,deleteAction, putAction} from '@/api/manage'
  import FxCompontensModal from "@/components/jeecgbiz/FxCompontensModal"
  import ProgramInfoModal from './/ProgramInfoModal.vue'
 


  export default {
    name: "PackingSpecificationMaintainBottom",
    mixins:[JeecgListMixin],
    components: {
      JSuperQuery,
      FxCompontensModal,
      ProgramInfoModal,
    },

    props: {
      mcode: {
        type: String,
        default: ''
      },
    },    
    data () {
      return {
        superQueryFlag:false,
        superQueryParams: '',
        description: '标签模板维护管理页面',
        cgButtonLinkList:[],
        title:'',//存表名
        EnhanceJS:'',
        cgButtonList:[],
        groupTag:[],
        queryInfo: [],
        code: '',
        // 表头
        columns: [
        ],
        //列设置
        settingColumns:[],
        //列定义
        defColumns: [
          {
            title: "序号",
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align: 'center',
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '产品编码',
            align: 'center',
            dataIndex: 'productCode'
          },
          {
            title: '产品名称',
            align: 'center',
            dataIndex: 'productName'
          },
          {
            title: '产品描述',
            align: 'center',
            dataIndex: 'productSpec'
          },
          {
            title: '产品规格',
            align: 'center',
            dataIndex: 'productStandard'
          },
          {
            title: '纸箱长',
            align: 'center',
            dataIndex: 'boxLength',
            customRender:function (t,r,index) {
              return t + 'mm';
            }            
          },
          {
            title: '纸箱宽',
            align: 'center',
            dataIndex: 'boxWidth',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '纸箱高',
            align: 'center',
            dataIndex: 'boxHigh',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '捆扎次数',
            align: 'center',
            dataIndex: 'bindNumber',               
          },
          {
            title: '码垛层数',
            align: 'center',
            dataIndex: 'stackingLayers',
          },
          {
            title: '每层放置数',
            align: 'center',
            dataIndex: 'horizontalNumber',
          },
          {
            title: '水平捆包数',
            align: 'center',
            dataIndex: 'horStrapNumber',
          },
          {
            title: '垂直捆包数',
            align: 'center',
            dataIndex: 'virStrapNumber',
          },
          {
            title: '托盘长度',
            align: 'center',
            dataIndex: 'palletLength',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '托盘宽度',
            align: 'center',
            dataIndex: 'palletWidth',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '护角高度',
            align: 'center',
            dataIndex: 'angleHigh',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '盖板长度',
            align: 'center',
            dataIndex: 'coverPlateLength',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '盖板宽度',
            align: 'center',
            dataIndex: 'coverPlateWidth',
            customRender:function (t,r,index) {
              return t + 'mm';
            }                
          },
          {
            title: '满箱数量',
            align: 'center',
            dataIndex: 'trunkFul',             
          },
          {
            title: '满盒数量',
            align: 'center',
            dataIndex: 'fullBoxSize',             
          },
          {
            title: '创建时间 ',
            align: 'center',
            dataIndex: 'updateTime',
            customRender:function (text) {
              return timestampToDatetime(text)
            },
          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'status',
            scopedSlots: {customRender: 'status'},
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            width:110,
            fixed: 'right',
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: '/mes-craft/craft/mesPeSpecifications/list',
          delete: '/mes-craft/craft/mesPeSpecifications/delete',
          deleteBatch: '/mes-code/mesBcTemplate',
          exportXlsUrl: '/mes-craft/mesPeProcedure/export',
          getColumns: '/mes-code/online/cgform/api/getColumns/',
          EditSprc: '/mes-craft/craft/mesPeSpecifications/edit'
        },
        dictOptions:{},
        isShowEditSprcModal: false,
        other: '',
        form: {
          fullBoxSize: '',
          trunkFul: '',
          horizontalNumber: '',
          stackingLayers: '',
          horStrapNumber: '',
          virStrapNumber: '',
          boxLength: '',
          boxWidth: '',
          boxHigh: '',
          productCode: '',
        },
      rules: {
        boxLength: [
          { required: true, message: "请输入纸箱长", trigger: "blur" },
        ],
        boxWidth: [
          { required: true, message: "请输入纸箱宽", trigger: "blur" },
        ],

        boxHigh: [{ required: true, message: "请输入纸箱高", trigger: "blur" }],

        bindNumber: [
          { required: true, message: "请输入捆扎次数", trigger: "blur" },
        ],
        stackingLayers: [
          { required: true, message: "码垛层数", trigger: "blur" },
        ],
        horizontalNumber: [
          { required: true, message: "每层放置数", trigger: "blur" },
        ],
        horStrapNumber: [
          { required: true, message: "水平捆包数", trigger: "blur" },
        ],
        virStrapNumber: [
          { required: true, message: "垂直捆包数", trigger: "blur" },
        ],

        palletLength: [
          { required: true, message: "托盘长度", trigger: "blur" },
        ],

        palletWidth: [{ required: true, message: "托盘宽度", trigger: "blur" }],
        angleHigh: [{ required: true, message: "护角高度", trigger: "blur" }],

        coverPlateLength: [
          { required: true, message: "盖板长度", trigger: "blur" },
        ],
        coverPlateWidth: [
          { required: true, message: "盖板宽度", trigger: "blur" },
        ],

        trunkFul: [{ required: true, message: "满箱数量", trigger: "blur" }],

        fullBoxSize: [{ required: true, message: "满盒数量", trigger: "blur" }],
      },

      }
    },

    watch: {
      mcode: function(val){
        console.log(2);
        console.log('val', val);
        
        if (val != ''){
          this.queryParam.productCode = val
          this.loadData(1)
        }
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${api.test}${this.url.importExcelUrl}`;
      },
     getWidth:function(){
       if(this.defColumns.length > 14){
         return {width : '500px'}
       }
     },
     tableScroll:function(){
         if(this.columns.length > 13){
             return { x: this.columns.length*150-450 }
         }
     }
    },
    created() {
      this.queryParam.productCode = this.mcode
      this.initButtonList();
      this.initColumns();
    },

methods: {

      loadData(arg) {
        if (!this.url || !this.url.list) {
          console.log('请设置url.list属性!')
          return
        }
        // 加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1
        }
        var params = this.getQueryParams() // 查询条件
        this.loading = true
        console.log('params', params);
        if ( !('productCode' in params)) {
          return
        }

        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.data.records
            this.ipagination.total = res.data.total
          }
          if (res.code === 510) {
            this.$message.warning(res.msg)
          }
          this.loading = false
        })
      },

      onSwitchChange(record){
        console.log(record);
        const params = {
          status: record.status ? 1 : 0,
          id: record.id,
        }
        putAction(this.url.EditSprc, params).then( res => {
          if (res.success) {
            this.$message.success("修改状态成功!")
          } else {
            this.$message.error("修改状态失败!")
            record.status = !record.status
          }
        } )
      },

      initColumns(){
        //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
        //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');
        var key = this.$route.name+":colsettings";
        let colSettings= Vue.ls.get(key);
        if(colSettings==null||colSettings==undefined){
          let allSettingColumns = [];
          this.defColumns.forEach(function (item,i,array ) {
            allSettingColumns.push(item.dataIndex);
          })
          this.settingColumns = allSettingColumns;
          this.columns = this.defColumns;
        }else{
          this.settingColumns = colSettings;
          const cols = this.defColumns.filter(item => {
            if(item.key =='rowIndex'|| item.dataIndex=='action'){
              return true;
            }
            if (colSettings.includes(item.dataIndex)) {
              return true;
            }
            return false;
          })
          this.columns =  cols;
        }
      },
      //列设置更改事件
      onColSettingsChange (checkedValues) {
        var key = this.$route.name+":colsettings";
        Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
        this.settingColumns = checkedValues;
        const cols = this.defColumns.filter(item => {
          if(item.key =='rowIndex'|| item.dataIndex=='action'){
            return true
          }
          if (this.settingColumns.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns =  cols;
      },


      // 弹出窗组件
      showDemoModal() {
        this.$refs.modalCompon.modalShow();
      },
      // 点击btn获取数据
      btnGetData(tableName,title){
        getAction(`${this.url.getColumns}`,{
          tableName:tableName
        }).then(
          res=>{
            if(res.code == 0){
              this.queryInfo = res.data.columns
              this.title = title
              this.dictOptions = res.data.dictOptions
              this.showDemoModal()
            }else{
               this.$message.warning(res.msg);
            }
          }
        )
      },

      //筛选分组
      getGroupTag(arrList) {
        let arr = [];
        var map = {},
            dest = [];
        arrList.forEach((item, index) => {
          if (item.groupTag) {
            arr.push(item);
          }
        });
        for (var i = 0; i < arr.length; i++) {
          var ai = arr[i];
          if (!map[ai.groupTag]) {
            dest.push({
              groupTag: ai.groupTag,
              name: ai.groupName,
              data: [ai]
            });
            map[ai.groupTag] = ai;
          } else {
            for (var j = 0; j < dest.length; j++) {
              var dj = dest[j];
              if (dj.groupTag == ai.groupTag) {
                dj.data.push(ai);
                break;
              }
            }
          }
        }
        this.groupTag = dest
        console.log(dest);
      },
      showLinkButton(item,record){
          let btn = new ButtonExpHandler(item.exp,record);
          return btn.show;
      },
        initButtonList(){
          getAction(`${this.url.getColumns}8ac49ec7733bce48017345d5867f0074`).then((res)=>{
            console.log("--获取自定义按钮->>",res);
            if(res.success){
              this.code = res.data.code;
              this.initCgButtonList(res.data.cgButtonList);
              this.initCgEnhanceJs(res.data.enhanceJs);
              this.getGroupTag(res.data.cgButtonList);
            }else{
              this.$message.warning(res.msg)
            }
          })
        },
        initCgEnhanceJs(enhanceJs){
          //console.log("--onlineList-js增强",enhanceJs)
          if(enhanceJs){
            let Obj = eval ("(" + enhanceJs + ")");
            this.EnhanceJS = new Obj(getAction,postAction,deleteAction);
            this.cgButtonJsHandler('created')
          }else{
            this.EnhanceJS = ''
          }
        },
        initCgButtonList(btnList){
          let linkArr = []
          let buttonArr = []
          if(btnList && btnList.length>0){
            for(let i=0;i<btnList.length;i++){
              let temp = btnList[i]
              if(temp.buttonStyle=='button'){
                buttonArr.push(temp)
              }else if(temp.buttonStyle=='link'){
                linkArr.push(temp)
              }
            }
          }
          this.cgButtonLinkList = [...linkArr]
          this.cgButtonList=[...buttonArr]
          console.log("链接增强", this.cgButtonLinkList);
        },
        cgButtonJsHandler(buttonCode){
          if(this.EnhanceJS[buttonCode]){
            this.EnhanceJS[buttonCode](this)
          }
        },
        cgButtonActionHandler(buttonCode){
          //处理自定义button的 需要配置该button自定义sql
          if(!this.selectedRowKeys || this.selectedRowKeys.length==0){
            this.$message.warning("请先选中一条记录")
            return false
          }
          if(this.selectedRowKeys.length>1){
            this.$message.warning("请只选中一条记录")
            return false
          }
          let params = {
            formId:this.code,
            buttonCode:buttonCode,
            dataId:this.selectedRowKeys[0]
          }
          console.log("自定义按钮请求后台参数：",params)
          postAction(this.url.buttonAction,params).then(res=>{
            if(res.success){
              this.loadData()
              this.$message.success("处理完成!")
            }else{
              this.$message.warning("处理失败!")
            }
          })

        },

        testPost(){
          getAction(this.url.list,{  
            pageNo: 1,
            limit: 10
          }).then(res=>{
            if(res.success){
              this.loadData()
              this.$message.success("处理完成!")
            }else{
              this.$message.warning("处理失败!")
            }
          })
        },

        cgButtonLinkHandler(record,buttonCode,optType){
          if(optType=="js"){
            if(this.EnhanceJS[buttonCode]){
              this.EnhanceJS[buttonCode](this,record)
            }
          }else if(optType=="action"){
            let params = {
              formId:this.code,
              buttonCode:buttonCode,
              dataId:record.id
            }
            console.log("自定义按钮link请求后台参数：",params)
            postAction(this.url.buttonAction,params).then(res=>{
              if(res.success){
                this.loadData()
                this.$message.success("处理完成!")
              }else{
                this.$message.warning("处理失败!")
              }
            })
          }
        },
        handleDelete: function (id) {
          if (!this.url.delete) {
            this.$message.error('请设置url.delete属性!')
            return
          }
          var that = this
          deleteAction(that.url.delete, {id}).then((res) => {
            if (res.success) {
              that.$message.success(res.msg)
              console.log('删除成功');
              this.$parent.updateHasSpecification( this.mcode, false)
              that.loadData()
            } else {
              that.$message.warning(res.msg)
            }
          })
        },
        batchDel: function () {
          if (!this.url.deleteBatch) {
            this.$message.error('请设置url.deleteBatch属性!')
            return
          }
          if (this.selectedRowKeys.length <= 0) {
            this.$message.warning('请选择一条记录！')
          } else {
            var ids = ''
            for (var a = 0; a < this.selectedRowKeys.length; a++) {
              ids += this.selectedRowKeys[a] + ','
            }
            var that = this
            this.$confirm({
              title: '确认删除',
              content: '是否删除选中数据?',
              onOk: function () {
                that.loading = true
                deleteAction(that.url.deleteBatch + `/${ids}`, {}).then((res) => {
                  if (res.success) {
                    that.$message.success(res.msg)
                    that.loadData()
                    that.onClearSelected()
                  } else {
                    that.$message.warning(res.msg)
                  }
                }).finally(() => {
                  that.loading = false
                })
              }
            })
          }
        },

      showEditSprcModal(record) {
        this.isShowEditSprcModal = true
        this.form = JSON.parse(JSON.stringify(record)) 
        console.log(this.form);
      },   
      cancelEditSprc(){
        this.form = this.$options.data().form
        this.isShowEditSprcModal = false
      },
      okEditSprc(){
        this.$refs.ruleForm.validate(valid => {
          if (valid) {
            const params = JSON.parse(JSON.stringify(this.form))
            delete params.timestamp
            putAction(this.url.EditSprc, params).then( res => {
              if (res.success) {
                // this.loadData()
                this.$message.success('处理完成!')
                this.loadData(1)

                this.isShowEditSprcModal = false
              } else {
                this.$message.warning('处理失败!')
              }          
            })
          } else {
            console.log('error submit!!');
            return false;
          }
        }) 
        
      },
      limitNumber(value) {
        if (typeof value === "string") {
          return !isNaN(Number(value)) ? value.replace(/\./g, "") : 0;
        } else if (typeof value === "number") {
          return !isNaN(value) ? String(value).replace(/\./g, "") : 0;
        } else {
          return 0;
        }
      },      
    }
  }
</script>


<style scoped>
  @import '~@assets/less/common.less';
</style>

<style lang="less" scoped>
  .warning-value{
    p {
      text-align: right;
      .warning-value-title {
        color: #40a9ff;
        cursor: pointer;
      }
      .warning-value-num {
        color: red;
      }
    }
  }

</style>